<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="shortcut icon" href="{{url_for('static',filename='icon/favicon.ico')}}" type="image/x-icon">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="{{url_for('static',filename='css/bootstrap.min.css')}}">
    <link rel="stylesheet" href="{{url_for('static',filename='css/floating-labels.css')}}">
    <script type="text/javascript" src="{{url_for('static',filename='js/jquery-3.3.1.min.js')}}"></script>
    <script type="text/javascript" src="{{url_for('static',filename='js/bootstrap.min.js')}}"></script>
    <title>Char-RNN-Writer</title>
    <script type=text/javascript>
        $SCRIPT_ROOT = {{ request.script_root|tojson|safe }};
    </script>
    <script type="text/javascript">
        window.history.replaceState(null, null, window.location.href);
    </script>
</head>
<body class="bg-light">
    <div class="container">
        <form class="form-signin">
            <div class="text-center mb-4">
                <h1 class="h3 mb-3 font-weight-normal">Char-RNN-Writer</h1>
                <p>Char-RNN模型是从字符的维度上，让机器生成文本，即通过已经观测到的字符出发，预测下一个字符出现的概率，也就是对序列数据的推测。<code>写诗项目</code>：<a
                        href="https://github.com/yanqiangmiffy/char-rnn-writer">GitHub传送门</a></p>
            </div>

            <div class="form-label-group">
                <input type="text" id="begin_word" name="begin_word" class="form-control" placeholder="开始的字符" required
                       autofocus>
                <label for="begin_word">输入诗的第一个字，如“夜”</label>
            </div>
            <button class="btn btn-lg btn-primary btn-block" id="submit" type="submit">写诗</button>
        </form>
        <div class="text-center">
            <p class="text-primary" id="result">
                夜皆凤义花，浮云引艳切。<br>红进双柳赠，风雨万声和。
            </p>
        </div>
        <p class="mt-5 mb-3 text-muted text-center">&copy; 2018.07-2018.08</p>

    </div>

    <script type=text/javascript>
      $(function() {
        $('button#submit').bind('click', function() {
          $.getJSON($SCRIPT_ROOT + '/write_poem', {
            begin_word: $('input[id="begin_word"]').val(),
          }, function(data) {
            $("#result").text(data.result);
          });
          return false;
        });
      });
    </script>
</body>
</html>